/**
 * 用户列表相关接口
 */
import request from '@/utils/request.js'

/**
 * 查询分页
 */
export const getList = (current, limit, search) => {
  return request({
    url: '/system/role/list',
    method: 'GET',
    params: {
      ...search,
      current,
      limit
    },
  })
}

/**
 * 修改
 */
export const update = (row) => {
  return request({
    url: '/system/role',
    method: 'PUT',
    data: row,
  })
}

// 删除多个 （常用）
export const remove = (ids) => {
  return request({
    url: "/system/role/remove",
    method: 'DELETE',
    params: {
      ids
    }
  })
}

/**
* 获取详情数据
*/
export const getNotice = (id) => {
  return request({
    url: `/system/role/${id}`,
    method: 'GET',
  })
}

/**
* 添加数据
*/
export const add = (row) => {
  return request({
    url: '/system/role',
    method: 'POST',
    data: row,
  })
}

/**
 * 获取当前角色菜单权限
 */
export const getMenuAuth = (id) => {
  return request({
    url: '/system/role/menuPermission/' + id,
    method: 'GET',
  })
}

/**
 * 设置用户权限
 */
export const setMenuAuth = (id, ids) => {
  return request({
    url: "/system/role/roleMenu/" + id,
    method: 'PUT',
    data: ids,
  })
}

/**
 * 获取绑定当前角色的用户
 */
export const getBindRoleUserList = (id, current, limit, search) => {
  return request({
    url: "/system/role/authUser/allocatedList/" + id,
    method: 'GET',
    params: {
      ...search,
      current,
      limit
    },
  })
}

/**
 * 获取绑定当前角色的用户
 */
export const getNotBindingUserList = (id, current, limit, search) => {
  return request({
    url: "/system/role/authUser/unallocatedList/" + id,
    method: 'GET',
    params: {
      ...search,
      current,
      limit
    },
  })
}

/**
 * 取消绑定用户
 */
export const cancelAuthUser = (roleId, userIds) => {
  return request({
    url: "/system/role/authUser/cancel",
    method: 'PUT',
    params: {
      roleId,
      userIds
    }
  })
}

/**
 * 为角色绑定用户
 */
export const addlAuthUser = (roleId, userIds) => {
  return request({
    url: "/system/role/authUser/accredit",
    method: 'PUT',
    params: {
      roleId,
      userIds
    }
  })
}

/**
 * 获取树形结构
 */
export const getRoleTree = () => {
  return request({
    url: "/system/role/roleTree",
    method: 'GET',
  })
}

/**
 * 修改角色状态
 */
export const updateRoleStatus = (roleId, status) => {
  return request({
    url: "/system/role/authUser/status",
    method: "PUT",
    params: {
      roleId,
      status
    }
  })
}

/**
 * 查看角色拥有哪些数据权限
 */
export const getRolDateScope = (roleId) => {
  return request({
    url: "/system/role/authUser/dateScope/" + roleId,
    method: "GET"
  })
}

/**
 * 设置角色拥有哪些数据权限
 */
export const setRolDateScope = (form) => {
  return request({
    url: "/system/role/authUser/dateScope",
    method: "PUT",
    data: {
      ...form
    }
  })
}